﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/includes/main.master"
    Async="true" CodeFile="email.aspx.cs" Inherits="subscribe_email" Title="Subscribe to CompareXpress" %>

<%@ Register Src="~/controls/usrNoJS.ascx" TagName="usrNoJS" TagPrefix="ucNoJS" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager ID="ScriptManager" runat="server">
    </asp:ScriptManager>
    <link rel="stylesheet" type="text/css" href="../css/forms_results.css" />
    <link rel="stylesheet" type="text/css" href="../css/button.css" />
    <ucNoJS:usrNoJS ID="usrNoJS1" runat="server" />
    <div class="elements_inner_wrapper">
        <div id="contentBody">
            <h3>
                Forward Promotion to Friends</h3>
            <asp:Panel runat="server" ID="pnlEmailThis" DefaultButton="btnEmailThis">
                <table cellpadding="0" cellspacing="0" border="0" class="table_details" style="width: 580px;">
                    <tr>
                        <td width="220">
                        </td>
                        <td class="bg_grey_2" width="360">
                            <div>
                                <div class="curvetopleft left">
                                </div>
                                <div class="curvetopright right">
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="txtleft pad7px border1pxdotb_light">
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:Label ID="lblMessage" ForeColor="Red" runat="server"></asp:Label>
                            <asp:ValidationSummary ID="ValidationSummary1" CssClass="errorSummary" HeaderText="Oops... Please complete the form"
                                runat="server" ValidationGroup="emailthis" />
                        </td>
                    </tr>
                    <tr>
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Your Name</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:TextBox ID="txtFullName" Width="250" MaxLength="80" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtFullName" runat="server" ControlToValidate="txtFullName"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Your E-mail</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:TextBox ID="txtEmail" runat="server" Width="250" MaxLength="100"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtEmail" runat="server" ControlToValidate="txtEmail"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator validationErrorCssClass="validationError" ID="revtxtEmail"
                                runat="server" ValidationGroup="emailthis" ErrorMessage="" Text="" ControlToValidate="txtEmail"
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr>
                        <td class="txtleft pad7px border1pxdotb_light">
                            Number of Friends
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:DropDownList runat="server" ID="ddlNoOfFriends" onchange="ShowFriendControls()">
                                <asp:ListItem Value="0">Select</asp:ListItem>
                                <asp:ListItem Value="1">1</asp:ListItem>
                                <asp:ListItem Value="2">2</asp:ListItem>
                                <asp:ListItem Value="3">3</asp:ListItem>
                                <asp:ListItem Value="4">4</asp:ListItem>
                                <asp:ListItem Value="5">5</asp:ListItem>
                            </asp:DropDownList> 
                            <asp:RequiredFieldValidator ID="rfvddlNoOfFriends" runat="server" ControlToValidate="ddlNoOfFriends" InitialValue="0"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr id="trFriend1" style="display: none;">
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Friend's Name 1</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:TextBox ID="txtFriendName1" Width="250" MaxLength="80" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtFriendName1" runat="server" ControlToValidate="txtFriendName1"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr id="trFriendEmail1" style="display: none;">
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Friend's E-mail 1</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:TextBox ID="txtEmailFriend1" runat="server" Width="250" MaxLength="100"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtEmailFriend1" runat="server" ControlToValidate="txtEmailFriend1"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator validationErrorCssClass="validationError" ID="revtxtEmailFriend1"
                                runat="server" ValidationGroup="emailthis" ErrorMessage="" Text="" ControlToValidate="txtEmailFriend1"
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr id="trFriend2" style="display: none;">
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Friend's Name 2</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:TextBox ID="txtFriendName2" Width="250" MaxLength="80" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtFriendName2" runat="server" ControlToValidate="txtFriendName2"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr id="trFriendEmail2" style="display: none;">
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Friend's E-mail 2</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:TextBox ID="txtEmailFriend2" runat="server" Width="250" MaxLength="100"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtEmailFriend2" runat="server" ControlToValidate="txtEmailFriend2"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator validationErrorCssClass="validationError" ID="revtxtEmailFriend2"
                                runat="server" ValidationGroup="emailthis" ErrorMessage="" Text="" ControlToValidate="txtEmailFriend2"
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr id="trFriend3" style="display: none;">
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Friend's Name 3</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:TextBox ID="txtFriendName3" Width="250" MaxLength="80" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtFriendName3" runat="server" ControlToValidate="txtFriendName3"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr id="trFriendEmail3" style="display: none;">
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Friend's E-mail 3</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:TextBox ID="txtEmailFriend3" runat="server" Width="250" MaxLength="100"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtEmailFriend3" runat="server" ControlToValidate="txtEmailFriend3"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator validationErrorCssClass="validationError" ID="revtxtEmailFriend3"
                                runat="server" ValidationGroup="emailthis" ErrorMessage="" Text="" ControlToValidate="txtEmailFriend3"
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr id="trFriend4" style="display: none;">
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Friend's Name 4</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:TextBox ID="txtFriendName4" Width="250" MaxLength="80" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtFriendName4" runat="server" ControlToValidate="txtFriendName4"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr id="trFriendEmail4" style="display: none;">
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Friend's E-mail 4</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:TextBox ID="txtEmailFriend4" runat="server" Width="250" MaxLength="100"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtEmailFriend4" runat="server" ControlToValidate="txtEmailFriend4"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator validationErrorCssClass="validationError" ID="revtxtEmailFriend4"
                                runat="server" ValidationGroup="emailthis" ErrorMessage="" Text="" ControlToValidate="txtEmailFriend4"
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr id="trFriend5" style="display: none;">
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Friend's Name 5</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:TextBox ID="txtFriendName5" Width="250" MaxLength="80" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtFriendName5" runat="server" ControlToValidate="txtFriendName5"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr id="trFriendEmail5" style="display: none;">
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Friend's E-mail 5</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:TextBox ID="txtEmailFriend5" runat="server" Width="250" MaxLength="100"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtEmailFriend5" runat="server" ControlToValidate="txtEmailFriend5"
                                Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="emailthis" validationErrorCssClass="validationError">
                            </asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator validationErrorCssClass="validationError" ID="revtxtEmailFriend5"
                                runat="server" ValidationGroup="emailthis" ErrorMessage="" Text="" ControlToValidate="txtEmailFriend5"
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr>
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Security Check</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:UpdatePanel runat="server" ID="uplCAPCHA">
                                <ContentTemplate>
                                    <asp:Image ID="imgCAPTCHA" runat="server" />
                                    <asp:ImageButton ID="btnNewImage" runat="server" OnClick="btnNewImage_Click" ImageUrl="~/images/icons/refresh.gif"
                                        ToolTip="Reload" AlternateText="Refresh" />
                                </ContentTemplate>
                            </asp:UpdatePanel>
                            <asp:UpdateProgress AssociatedUpdatePanelID="uplCAPCHA" DisplayAfter="100" runat="server"
                                ID="udpCAPTCHA">
                                <ProgressTemplate>
                                    <asp:Image ID="imgLoading" ImageUrl="~/images/loading7.gif" runat="server" />
                                </ProgressTemplate>
                            </asp:UpdateProgress>
                        </td>
                    </tr>
                    <tr>
                        <td class="txtleft pad7px border1pxdotb_light">
                            <strong>Text in Box</strong>
                        </td>
                        <td class="bg_grey_2 pad7px border2pxdotb">
                            <asp:UpdatePanel ID="uplSecurityCode" runat="server">
                                <ContentTemplate>
                                    <span class="indicator">
                                        <asp:TextBox ID="txtSecurityCode" Width="200px" MaxLength="20" runat="server"></asp:TextBox>
                                    </span><span class="indicator">
                                        <asp:RequiredFieldValidator ID="rfvSecurityCheck" runat="server" ControlToValidate="txtSecurityCode"
                                            Display="Dynamic" ErrorMessage="" validationErrorCssClass="validationError" Text=""
                                            ValidationGroup="emailthis"></asp:RequiredFieldValidator>
                                    </span>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                    </tr>
                    <tr>
                        <td class="txtleft pad7px">
                        </td>
                        <td class="bg_grey_2 pad7px">
                            <asp:Button runat="server" ID="btnEmailThis" CssClass="button_email-this" OnClick="btnEmailThis_Click"
                                OnClientClick="LoadValidationErrorCss(); ValidateControls(); if (Page_ClientValidate('emailthis')){ this.className = 'button_processing';}"
                                ValidationGroup="emailthis" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td class="bg_grey_2 w210px">
                            <div>
                                <div class="curvebottomleft left">
                                </div>
                                <div class="curvebottomright right">
                                </div>
                            </div>
                        </td>
                    </tr>
                </table>
                <asp:Button runat="server" ID="btnBack" Visible="true" onmousedown="this.className = 'button_back_mousedown';"
                    onmouseout="this.className = 'button_back';" onmouseup="this.className = 'button_back';"
                    CssClass="button_back" CausesValidation="false" OnClientClick="this.removeAttribute('onmouseout');this.removeAttribute('onmouseup'); this.className = 'button_processing';"
                    OnClick="btnBack_Click" />
            </asp:Panel>
        </div>
    </div>

    <script type="text/javascript">
        window.onload = function() {
            //document.getElementById('<%=ddlNoOfFriends.ClientID%>').value = 0;
            ShowFriendControls();
        }
        function ShowFriendControls() {
            
            document.getElementById('trFriend1').style.display = 'none';
            document.getElementById('trFriendEmail1').style.display = 'none';
            document.getElementById('trFriend2').style.display = 'none';
            document.getElementById('trFriendEmail2').style.display = 'none';
            document.getElementById('trFriend3').style.display = 'none';
            document.getElementById('trFriendEmail3').style.display = 'none';
            document.getElementById('trFriend4').style.display = 'none';
            document.getElementById('trFriendEmail4').style.display = 'none';
            document.getElementById('trFriend5').style.display = 'none';
            document.getElementById('trFriendEmail5').style.display = 'none';
            
            var NoOfFriend = document.getElementById('<%=ddlNoOfFriends.ClientID%>').value;

            if (NoOfFriend == 1) {
                document.getElementById('trFriend1').style.display = '';
                document.getElementById('trFriendEmail1').style.display = '';
            }

            if (NoOfFriend == 2) {
                document.getElementById('trFriend1').style.display = '';
                document.getElementById('trFriendEmail1').style.display = '';
                document.getElementById('trFriend2').style.display = '';
                document.getElementById('trFriendEmail2').style.display = '';
            }

            if (NoOfFriend == 3) {
                document.getElementById('trFriend1').style.display = '';
                document.getElementById('trFriendEmail1').style.display = '';
                document.getElementById('trFriend2').style.display = '';
                document.getElementById('trFriendEmail2').style.display = '';
                document.getElementById('trFriend3').style.display = '';
                document.getElementById('trFriendEmail3').style.display = '';
            }

            if (NoOfFriend == 4) {
                document.getElementById('trFriend1').style.display = '';
                document.getElementById('trFriendEmail1').style.display = '';
                document.getElementById('trFriend2').style.display = '';
                document.getElementById('trFriendEmail2').style.display = '';
                document.getElementById('trFriend3').style.display = '';
                document.getElementById('trFriendEmail3').style.display = '';
                document.getElementById('trFriend4').style.display = '';
                document.getElementById('trFriendEmail4').style.display = '';
            }

            if (NoOfFriend == 5) {
                document.getElementById('trFriend1').style.display = '';
                document.getElementById('trFriendEmail1').style.display = '';
                document.getElementById('trFriend2').style.display = '';
                document.getElementById('trFriendEmail2').style.display = '';
                document.getElementById('trFriend3').style.display = '';
                document.getElementById('trFriendEmail3').style.display = '';
                document.getElementById('trFriend4').style.display = '';
                document.getElementById('trFriendEmail4').style.display = '';
                document.getElementById('trFriend5').style.display = '';
                document.getElementById('trFriendEmail5').style.display = '';
            }
        
        }

        function ValidateControls() {

            var NoOfFriend = document.getElementById('<%=ddlNoOfFriends.ClientID%>').value;

            ValidatorEnable(document.getElementById('<%=rfvtxtFriendName2.ClientID%>'), false);
            ValidatorEnable(document.getElementById('<%=rfvtxtFriendName3.ClientID%>'), false);
            ValidatorEnable(document.getElementById('<%=rfvtxtFriendName4.ClientID%>'), false);
            ValidatorEnable(document.getElementById('<%=rfvtxtFriendName5.ClientID%>'), false);
            
            ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend2.ClientID%>'), false);
            ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend3.ClientID%>'), false);
            ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend4.ClientID%>'), false);
            ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend5.ClientID%>'), false);

            //alert(NoOfFriend);

            if (NoOfFriend == 2) {
                ValidatorEnable(document.getElementById('<%=rfvtxtFriendName2.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend2.ClientID%>'), true);
            }

            if (NoOfFriend == 3) {
                ValidatorEnable(document.getElementById('<%=rfvtxtFriendName2.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend2.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtFriendName3.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend3.ClientID%>'), true);
            }

            if (NoOfFriend == 4) {
                ValidatorEnable(document.getElementById('<%=rfvtxtFriendName2.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend2.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtFriendName3.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend3.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtFriendName4.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend4.ClientID%>'), true);
            }

            if (NoOfFriend == 5) {
                ValidatorEnable(document.getElementById('<%=rfvtxtFriendName2.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend2.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtFriendName3.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend3.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtFriendName4.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend4.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtFriendName5.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%=rfvtxtEmailFriend5.ClientID%>'), true);
            }

        }

     
    </script>

</asp:Content>
